Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #362
I'm not a big fan of globals (and I spent some time getting rid of them in #322), but since we emit this warning even on things like
x = Variable; y = Variable(); x*y
, there doesn't seem like a good place to pass in an argumentwarn=false
. Arguably we could only do the check when calculating thevexity
of aProblem
, and then pass warning info through the problem constructor. (We would need to also make sure you can see the check before starting a solve, etc..)However, (1) the way the
vexity
of aProblem
is written currently is a little strange and I'd prefer not to mess with it yet, and (2) it might be helpful that we are very eager to warn on non-DCPness (i.e., onx*y
instead of waiting for the user to put that inside aProblem
or call asolve!
), because it can help formulate a DCP problem easily, checking along the way, especially when you are first learning the rules.So for these reasons, I think a simple fix to the current way of emitting the warnings is best, namely to just check if warnings are enabled from a global before issuing one. In the interests of thread safety (since that appears to be a useful thing to do with Convex: #370),
I followed the pattern of https://discourse.julialang.org/t/attempting-to-make-my-module-code-threadsafe/30434/2 of making a vector of parameters indexed byI used atomics, and added some for the other globals (for printing width and depth).threadid()
. I think the same pattern is also used for Julia's RNG.